package ooday04;

import java.util.Scanner;

/*测试类*/
public class Tset {
    public static void main(String[] args) {
        //演示向上造型的第2点应用
        Animal[] animals = new Animal[6];
        animals[0] = new Dog("奥利奥",1,"黄");
        animals[1] = new Dog("奥利给",1,"白");
        animals[2] = new Fish("小花",1,"花");
        animals[3] = new Fish("小红",1,"红");
        animals[4] = new Chick("大黑",1,"黑");
        animals[5] = new Chick("大白",1,"白");

        for(int i = 0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

        if(animals[i] instanceof Dog){
            Dog dog = (Dog)animals[i];
            dog.lookHome();
            dog.swim();
        }

        if(animals[i] instanceof Fish){
            Fish fish = (Fish)animals[i];
            fish.swim();
        }

        if (animals[i] instanceof Swim){
            Swim s = (Swim)animals[i];
            s.swim();
        }

        if(animals[i] instanceof Chick){
             Chick chick = (Chick)animals[i];
             chick.layEggs();
        }
        }
    }
}